<?php
include_once("../../service/productService.php");
include_once("../../util/imageUtil.php");

$imgPaths = $_POST["imgPaths"];
$proId = $_POST["id"];
//$isSuccess = true;
$arrayOfImagePath = preg_split("/,/", $imgPaths);

//$imageList = findImagesOfProduct($proId);
//$insertedImages = array();
//while($row = ConnectionManager::getInstance()->fetch($imageList)){
//    $insertedImages[] = array("name" => $row["IMG_PATH"]);
//}

foreach($arrayOfImagePath as $each){
	if($each != "") {
		createNormalImage($proId, $each);
        crop(226, 299, "../../image/product/".$proId."/".$each, "../../image/product/".$proId."/thumbnail/".$each);
	}
	// check if an image was instert into database or not
	//$isExisted = false;
	//foreach($insertedImages as $aImage){
	//	if($each == $aImage["name"]) {
	//		$isExisted = true;
	//		break;
	//	}
	//}
	
	//if(!$isExisted && $each != "") creatNormalImage($proId, $each);
}
?>